<?php

class Topcmmchat_Service_Process extends Phpfox_Service
{
	public function updateSettings($aSettings)
	{

		$sTable = Phpfox::getT('chat_settings');
		$bResult = true;
		$bUpdate = $this->database()->update($sTable, array(
				'fc_extendserver' => $aSettings['fc_extendserver'],
				'fc_server_host' => $aSettings['fc_server_host'],
				'fc_server_port' => $aSettings['fc_server_port'],
				'fc_http_port' => $aSettings['fc_http_port'],
				'fc_client_loc' => $aSettings['fc_client_loc'],
				'fc_api_url' => $aSettings['fc_api_url'],
				'fc_room' => $aSettings['fc_room'],
				'fc_group' => $aSettings['fc_group'],
				'fc_room_list' => $aSettings['fc_room_list'],
				'fc_user_list' => $aSettings['fc_user_list'],
				'fc_fullscreen' => $aSettings['fc_fullscreen'],
				'fc_client_lang' => $aSettings['fc_client_lang'],
				'fc_client_skin' => $aSettings['fc_client_skin'],
				'fc_client_width' => $aSettings['fc_client_width'],
				'fc_client_height' => $aSettings['fc_client_height'],
		), 'id = 1');
		$bResult = $bResult && $bUpdate;
		$this->renewCache();
		return $bResult;
	}

	public function renewCache()
	{
		$this->cache()->remove('chat_settings');
		// reset the cache
		$this->cache()->set('chat_settings');
		$this->cache()->save('chat_settings', Phpfox::getService('topcmmchat')->getSettings());
	}
}

?>